package Utils;

import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Map;

public class Tool<T> {
    public static void main(String[] args) {
        String number= "123456";
        ;
        System.out.println(PositiveNumber(number));
    }
    public static boolean PositiveNumber(String ...text){
        try {
            for (int i = 0; i < text.length; i++) {
                int i1 = Integer.parseInt(text[i]);
                if (i1 <= 0){
                    return false;
                }
            }
        } catch (NumberFormatException e) {
            return false;
        } finally {
        }
        return true;
    }public static boolean Double(String name){

        try {
            Double.parseDouble(name);
        } catch (NumberFormatException e) {
           return false;
        } finally {
        }
        return true;
    }


    public static boolean isNULL(Object ...text){
        for (int i = 0; i < text.length; i++) {
            if (text[i] == null){
                return false;
            }
        }
        return true;
    }
    public static <T>T copy(Map vlue,T Bean){
        try {
            BeanUtils.populate(Bean,vlue);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        }
        return Bean;
    }
    public static Integer getNumber(String goal,int number){
        try {
            int i = Integer.parseInt(goal);
            return i;
        } catch (NumberFormatException e) {
            return number;
        } finally {
        }
    }
    private static SnowFlake snowFlake = new SnowFlake(0,0);

    public static Long getOrderNumber(){
        return snowFlake.nextId();
    }
    public static String getDateTime(){
        SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
        Date date = new Date(System.currentTimeMillis());
        return formatter.format(date);
    }

}
